package com.xuduo.amd.controller;

import com.xuduo.amd.dto.BusinessRequest;
import com.xuduo.amd.pojo.JsonResult;
import com.xuduo.amd.service.BusinessManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("eam/business")
public class BusinessManagerController {
    @Autowired
    private BusinessManagerService businessManagerService;

    @RequestMapping(value = "sysPage", method = RequestMethod.GET)
    public JsonResult SysPageInfo() {
        JsonResult jsonResult = new JsonResult();
        Map<String, Object> result = businessManagerService.selectSysInfo();
        jsonResult.setData(result);
        return jsonResult;

    }

    public JsonResult selectLike(@RequestBody BusinessRequest request) {
        JsonResult jsonResult = new JsonResult();
        if (!StringUtils.isEmpty(request.getName())) {
            List<Map<String, String>> result = businessManagerService.like(request.getName());
            jsonResult.setData(result);
        } else {
            jsonResult.setMessage("请输入系统名称");
            jsonResult.setState(1);
        }
        return jsonResult;
    }


}
